/**
 * @file security_common.h
 * @author yonglin_zhang
 * @brief 公共接口
 * @version 0.1
 * @date 2023-09-01
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include <stdio.h>

#include "security.h"

#define false 0
#define true  1
#define bool int8_t

#define INTERNAL_SECURITY_OK                            0x0000  // 接口调用成功
#define INTERNAL_SECURITY_PADDING_BUFFER_TOO_SMALL      0x0001  // 填充失败
#define INTERNAL_SECURITY_BAD_INPUT                     0x0002  // 非法输入
#define INTERNAL_SECURITY_UNPDADDING_FAILED             0x0003  // PKCS#7解填充失败

/**
 * @brief 0填充
 * 
 * @param out 
 * @param olen 
 * @param osize 
 * @param in 
 * @param inlen 
 * @return int 
 */
int padding_zero(char out[], size_t *olen, size_t osize, const char in[], size_t inlen);

/**
 * @brief pkcs7填充
 * 
 * @param out 
 * @param olen 
 * @param osize 
 * @param in 
 * @param inlen 
 * @param block_size 填充规定的块大小
 * @return int 
 */
int padding_pkcs7(char out[], size_t *olen, size_t osize, const char in[], size_t inlen, size_t block_size);

/**
 * @brief 0填充解填充
 * 
 * @param out 
 * @param olen 
 * @param osize 
 * @param in 
 * @param inlen 
 * @return int 
 */
int unpadding_zero(char out[], size_t *olen, size_t osize, const char in[], size_t inlen);

/**
 * @brief pkcs7填充解填充
 * 
 * @param out 
 * @param olen 
 * @param osize 
 * @param in 
 * @param inlen 
 * @return int 
 */
int unpadding_pkcs7(char out[], size_t *olen, size_t osize, const char in[], size_t inlen);